﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections;

namespace LHS.Core.Authority
{
    public class AuthorityController:MS.Core.Base.Controller.BaseController 
    {
        private CommonAuthority _objAuthority;

        private CommonAuthority objAuthority
        {
            get
            {
                if (_objAuthority == null)
                {
                    _objAuthority = new CommonAuthority();
                }
                return _objAuthority;
            }
        }

        /// <summary>
        /// Login vao he thong
        /// neu la lan dau : thi insert gia tri mac dinh vao he thong
        /// neu la lan thu 2 : thi kiem tra user name va password duoc dang nhap vao he thong 
        /// </summary>
        public DataTable  LoginSystem(string strUserName, string strPassword)
        {
            try
            {
              return objAuthority.LoginSystem(strUserName, strPassword);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// thay đổi password của bảng User
        /// </summary>
        /// <param name="strUserName"></param>
        /// <param name="strPassword"></param>
        /// <returns></returns>
        public void ChangePassword(string strUserName, string strPassword)
        {
            try
            {
                objAuthority.ChangePassword(strUserName, strPassword);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        
        /// <summary>
        /// thêm mới một user
        /// </summary>
        /// <param name="dr"></param>
        public void InsertUser(DataRow dr)
        {
            try
            {
                objAuthority.InsertUser(dr);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// backup tự động
        /// </summary>
        /// <param name="hashBackUp"></param>
        public void BackUpDatabaseAuto(Hashtable hashBackUp)
        {
            try
            {
                objAuthority.BackUpDatabaseAuto(hashBackUp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// backup bang tay
        /// </summary>
        /// <param name="hashBackUp"></param>
        public void BackUpDatabaseManual(Hashtable hashBackUp)
        {
            try
            {
                objAuthority.BackUpDatabaseManual(hashBackUp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// lay thong tin backup
        /// </summary>
        public DataTable  GetBackUpDT()
        {
            try
            {
               return objAuthority.GetBackUpDT();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
